﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:ESRI.ArcGIS.Client.Toolkit.DataSources.Gps;assembly=ESRI.ArcGIS.Client.Toolkit.DataSources"
	xmlns:esriConverters="clr-namespace:ESRI.ArcGIS.Client.ValueConverters;assembly=ESRI.ArcGIS.Client">

	<local:VisibleWhenAboveConverter x:Key="vizConv" />
	
	<ControlTemplate x:Key="GpsSymbolTemplate">
		<Grid Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}">
			<VisualStateManager.VisualStateGroups>
				<VisualStateGroup x:Name="SelectionStates">
					<!--Same state for selected and unselected. Flipping selection state triggers the strobe-->
					<VisualState x:Name="Selected">
						<Storyboard>
							<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="10" Duration="00:00:01" />
							<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="10" Duration="00:00:01" />
							<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" />
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Unselected">
						<Storyboard>
							<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="10" Duration="00:00:01" />
							<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" From="1" To="10" Duration="00:00:01" />
							<DoubleAnimation BeginTime="0" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)" From="1" To="0" Duration="00:00:01" />
						</Storyboard>
					</VisualState>
				</VisualStateGroup>
			</VisualStateManager.VisualStateGroups>
			<!--Strobe ellipse-->
			<Ellipse Height="13" Width="13" RenderTransformOrigin="0.5,0.5" x:Name="ellipse" IsHitTestVisible="False">
				<Ellipse.RenderTransform>
					<ScaleTransform />
				</Ellipse.RenderTransform>
				<Ellipse.Fill>
					<RadialGradientBrush>
						<GradientStop Color="#000099FF" Offset="0.4" />
						<GradientStop Color="#FF074297" Offset="0.5" />
						<GradientStop Color="#00D3D3D3" Offset="0.6" />
					</RadialGradientBrush>
				</Ellipse.Fill>
			</Ellipse>
			<!--Blue dot-->
			<Ellipse Stroke="#C4FFFFFF" StrokeThickness="1" >
				<Ellipse.Fill>
					<RadialGradientBrush Center="0.25,0.25" GradientOrigin="0.25,0.25" RadiusX="1" RadiusY="1" Opacity="0.97">
						<GradientStop Color="White" Offset="0"/>
						<GradientStop Color="#FFBFC0CC" Offset="0.039"/>
						<GradientStop Color="#FF5CFFA2" Offset="1"/>
						<GradientStop Color="#FF6A79F7" Offset="0.125"/>
						<GradientStop Color="#FF697CF7" Offset="0.539"/>
					</RadialGradientBrush>
				</Ellipse.Fill>
			</Ellipse>
			<!--Path showing the course of the symbol. This will only display when speed is > 1m/s -->
			<Path Data="M0,1 L.5,0 1,1 .5,.8 z" Stretch="Fill" Fill="White" Stroke="Black" StrokeThickness="1"
					RenderTransformOrigin=".5,.5" Margin="6,4,6,6"
				    Visibility="{Binding Symbol.Speed, Converter={StaticResource vizConv}, ConverterParameter=1}">
				<Path.RenderTransform>
					<RotateTransform Angle="{Binding Symbol.Course}"/>
				</Path.RenderTransform>
			</Path>
		</Grid>
	</ControlTemplate>
</ResourceDictionary>
